home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
ZIZ4LST.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-09
|
8KB
|
255 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: ziz4lst.cpp
// Title: 9 Digit ZIP Disc Interface
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
// This module contains code for the class ZI_Z4_LIST.
//
// The code in this module may be written in C++ or C.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
//
//----------------------------------------------------------------------------
#include <zi.hpp>
#define USE_WIN_Z4_LIST
#if OS_DOS
#include <zid.hpp>
#elif OS_WINDOWS
#include <ziw.hpp>
#else
#include <zio.hpp>
#endif
//----------------------------------------------------------------------------
// Description: Default constructor
// Parameters:
// Returns:
//----------------------------------------------------------------------------
FN_M ZI_Z4_LIST::ZI_Z4_LIST(SIZET cRecs, PRECID _precid)
: ZN_WINDOW("WIN_Z4_LIST", ZN_LOAD_CENTER|ZN_LOAD_HELPBAR|ZN_LOAD_NO_SHOW)
{
ZI_Z4_LIST::Initialize(CL_INIT_CLASS);
precid = _precid;
lRecords = (LONG)cRecs;
Setup();
}
//----------------------------------------------------------------------------
// Description: Destructor
// Parameters:
// Returns:
//----------------------------------------------------------------------------
FN_M ZI_Z4_LIST::~ZI_Z4_LIST()
{
ZI_Z4_LIST::Destroy(FALSE);
Terminate();
}
//----------------------------------------------------------------------------
// Description: Destroy object. Free any resources used by object.
// Normally called by destructor.
// Should allow multiple calls from various classes.
// A class should almost always re-init its variables when
// it is destroyed to prevent accidents.
// Parameters: fDestroyAll Destroy parents also?
// Default is TRUE.
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_M ZI_Z4_LIST::Destroy(BOOL fDestroyAll)
{
ZI_Z4_LIST::Initialize(CL_INIT_CLASS_VARS);
if (fDestroyAll) // Destroy parent.
ZI_Z4_LIST_PARENT::Destroy(fDestroyAll);
return TRUE;
}
//----------------------------------------------------------------------------
// Description: Initialize object.
// Normally called by constructor.
// Should allow multiple calls from various classes.
// Parameters: sInit Initialization code. May be one of the following:
// CL_INIT_CLASS Reset class variables and
// and dynamic allocations for
// this class only.
// CL_INIT_CLASS_VARS Reset class variables for
// this class only.
// CL_INIT_VARS Reset class variables for
// this class only.
// CL_INIT_ALL Initialize class and all
// parent class, including
// dynamic memory allocation.
// Default is CL_INIT_ALL
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_M ZI_Z4_LIST::Initialize(SHORT sInit)
{
if (sInit == CL_INIT_VARS || sInit == CL_INIT_ALL)
ZI_Z4_LIST_PARENT::Initialize(sInit);
lCurrent = 0;
lRecords = 0;
precid = NULL;
return TRUE;
}
//----------------------------------------------------------------------------
// Description: Set field values.
// Parameters:
// Returns: TRUE if valid
//----------------------------------------------------------------------------
BOOL FN_M ZI_Z4_LIST::Query(PZN_VLIST_ELEM pzn_vlist_elem)
{
pzn_vlist_elem->pszBuf = szFormat;
szFormat[0] = '\0';
if (!Z4_INQ::z4_file.Record(Z4_INQ::z4, precid[(SIZET)pzn_vlist_elem->lId]))
return FALSE;
if (!Z4_INQ::z5_file.Find(Z4_INQ::z5, Z4_INQ::z4.szZip5)
|| !Z4_INQ::cs_file.Best(Z4_INQ::cs, Z4_INQ::z5, Z4_INQ::z4.szLastLine))
memset(&Z4_INQ::cs, 0, sizeof(Z4_INQ::cs));
CHAR szSecRange[30];
CHAR szPriRange[30];
CHAR szAddr2[MAX_ADDR_LINE+5];
CHAR szLastLine[MAX_ADDR_LINE+5];
Z4_STANDARDIZE::SecRangeDisplay(szSecRange, Z4_INQ::z4);
Z4_STANDARDIZE::PriRangeDisplay(szPriRange, Z4_INQ::z4);
Z4_STANDARDIZE::Addr2Display(szAddr2, Z4_INQ::z4, "", "");
Z4_STANDARDIZE::LastLineDisplay(szLastLine, Z4_INQ::cs, Z4_INQ::z4.szZip5, Z4_INQ::z4.szAddonLo);
sprintf(szFormat, "\t%s\t%s\n\t%s\t%s\n\t%s",
Z4_INQ::z4.szSecName,
szSecRange,
szPriRange,
szAddr2,
szLastLine);
return TRUE;
}
//----------------------------------------------------------------------------
// Description: Event monitor function.
// Parameters: msg Event code
// pv1 Data pointer 1
// pv2 Data pointer 2
// Returns: Event code
//----------------------------------------------------------------------------
ZN_MSG FN_M ZI_Z4_LIST::User(ZN_MSG msg, PVOID pv1, PVOID pv2)
{
switch (msg)
{
case ZN_MSG_INIT:
return msg;
case ZN_MSG_TERMINATE:
return msg;
case ZN_MSG_VLIST_INIT:
{
static int aiTabstops[] = { 2, 45, 0, 2, 24, 0, 2, 0, 0 };
PZN_VLIST_INIT pzn_vlist_init = (PZN_VLIST_INIT)pv2;
pzn_vlist_init->lElems = lRecords;
pzn_vlist_init->fs = ZN_VLIST_SINGLE|ZN_VLIST_TITLE;
pzn_vlist_init->aiTabstops = aiTabstops;
}
return msg;
case ZN_MSG_VLIST_TITLE:
{
PZN_VLIST_ELEM pzn_vlist_elem = (PZN_VLIST_ELEM)pv2;
pzn_vlist_elem->pszBuf = szFormat;
strcpy(szFormat, "\tName\n\tRange\tStreet\n\tCity/State/ZIP");
}
return msg;
}
if (IsError()) // Error condition
return msg;
switch (msg)
{
case ZN_MSG_VLIST_QUERY:
Query((PZN_VLIST_ELEM)pv2);
break;
case ZN_MSG_VLIST_SELECT:
{
PZN_VLIST_ELEM pzn_vlist_elem = (PZN_VLIST_ELEM)pv2;
lCurrent = pzn_vlist_elem->lId;
}
// Fall through
case ZN_MSG_VLIST_CURRENT:
{
PZN_VLIST_ELEM pzn_vlist_elem = (PZN_VLIST_ELEM)pv2;
LONG lRec = pzn_vlist_elem->lId;
sprintf(szFormat, "Record %ld of %ld", lRec + 1, lRecords);
SetHelp(szFormat);
}
break;
case ZN_MSG_VLIST_DBL_CLK:
{
PZN_VLIST_ELEM pzn_vlist_elem = (PZN_VLIST_ELEM)pv2;
lCurrent = pzn_vlist_elem->lId;
}
case TB_SELECT:
SendMessage(ZiMainWindow(), ZI_MSG_SELECT, (PVOID)lCurrent);
Close();
break;
case ZN_MSG_HELP:
return ZN_MSG_NO_HELP;
case TB_GOTO:
ZI_GOTO::Goto(FID(Number()), lRecords, 1, lCurrent + 1);
break;
case ZI_MSG_GOTO:
SetVlistPos(((LONG)pv1) - 1);
break;
case TB_CLOSE:
Close();
break;
case TB_HELP:
NotDone();
break;
}
return msg;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------